<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Layui</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<link rel="stylesheet" href="/addons/hc_answer/template/plugins/layui/css/layui.css" media="all" />
	</head>

	<body>
		<div style="margin: 15px;">
			<fieldset class="layui-elem-field">
				<legend>用户通知</legend>
			
				<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
					<div class="layui-tab-content" >
						<!-- 基础设置 开始-->
						<form class="layui-form" action="" id="form">
							<div class="layui-form-item">
							    <label class="layui-form-label">类目</label>
							    <div class="layui-input-block">
							      <input type="text" name="keyword1" value="" lay-verify="required" placeholder="语文、数学、外语" autocomplete="off" class="layui-input layui-form-danger">
							    </div>
							</div>
							<div class="layui-form-item">
							    <label class="layui-form-label">数量</label>
							    <div class="layui-input-block">
							      <input type="text" name="keyword2" value="" lay-verify="required" placeholder="100道" autocomplete="off" class="layui-input layui-form-danger">
							    </div>
							</div>
							
							<div class="layui-form-item">
							    <div class="layui-input-block">
							      <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="demo1">通知所有人</button>
							    </div>
							</div>

							</form>
						<!-- 题目设置 结束-->
					</div>
				</div>	
			</fieldset>
		</div>

		<script type="text/javascript" src="/addons/hc_answer/template/plugins/layui/layui.js"></script>
		<script>
			layui.use(['form','laypage','layer'], function() {
				var $ = layui.jquery,
				form = layui.form();
				form.render();
				form.on('submit(demo1)', function(data) {
					$.ajax({
			            url:"{php echo $this->createWebUrl('sendlibtpl');php}",
			            data:$('#form').serialize(),
			            type:"post",
			            dataType:"json",
			            beforeSend:function(){
			            	layer.load(1, {
							  shade: [0.1,'#fff'] //0.1透明度的白色背景
							});
			            },
			            success:function(data){
			            	if(data.code=='1'){
			                	layer.alert(data.msg, {icon: 6},function(index){
			                		var index = parent.layer.getFrameIndex(window.name);
			                		parent.layer.close(index)
			                	});
								
			            	}else{
			                	layer.alert(data.msg, {icon: 5});
			            	}
			            },
			            error:function(data){
			                layer.alert('请稍后重试', {icon: 5});
			            }
			        });
					return false;
				});
				
			});
		</script>

	</body>

</html>